<?php 

class Catalogo_model extends CI_Model{ 
  private $_tabla = 'Catalogo';
  public $idCatalogo = 0;
  public $Titulo = "";
  public $idEditorial = 0;
  public $idIdioma = 0;
  public $idInstitucion = 0;
  public $lugarPublicacion = "";
  public $nroEdicion = 0;
  public $anioEdicion = 0;
  public $ISBN = "";
  public $paginas = 0;
  public $notas = 0;
  public $fechaAgregado = 0;
  public $incluyeSoftware = 0;
  public $descriptores = "";



    public function getAll(){
      return $this->db->get($this->_tabla)->result_array();
    }
    public function insert(){
      $this->db->insert($this->_tabla,$this);
    }

    public function update(){
    $this->db->where('idCatalogo', $this->idCatalogo);
    $this->db->update($this->_tabla,$this);
  }
  public function getById($id){
  $query = $this->db->query("SELECT * FROM " . $this->_tabla . " WHERE idCatalogo = '" . $id . "'");

   foreach ($query->result() as $row)
   {
    return $row;
   }
    }

  public function getLast(){
     return $this->db->query("SELECT idCatalogo from  catalogo where idCatalogo = (select max(idCatalogo) from ".$this->_tabla.")")->result_array();
  }

  public function getCondicionado($cons){
    return $this->db->query("SELECT * FROM ". $this->_tabla . $cons )->result_array();
  }
/*
select * from catalogo 
inner join catalogoautores
 on catalogo.idCatalogo = catalogoautores.idCatalogo
and catalogoautores.idautor = 4



select * from catalogo 
inner join catalogoautores
 on catalogo.idCatalogo = catalogoautores.idCatalogo
 inner join catalogocarreras
  on catalogo.idCatalogo = catalogocarreras.idCatalogo
and catalogoautores.idautor = 4
and catalogocarreras.idcarrera = 1


*/
}


  ?>

